/*
 *  Copyright (C) void Team 2010 Pedro Batista
 * 
 *  http://code.google.com/p/capacitec
 * 
 *  This file is part of capacitec.
 * 
 *  capacitec is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 * 
 *  capacitec is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with capacitec.  If not, see <http://www.gnu.org/licenses/>.
 */

package entidades;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author pedro
 */
@Entity
@Table(name = "turma", uniqueConstraints = {
	@UniqueConstraint(columnNames = {"id"})})
@NamedQueries({
	@NamedQuery(name = "Turma.findAll", query = "SELECT t FROM Turma t"),
	@NamedQuery(name = "Turma.findById", query = "SELECT t FROM Turma t WHERE t.id = :id"),
	@NamedQuery(name = "Turma.findByDataInicioProvavel", query = "SELECT t FROM Turma t WHERE t.dataInicioProvavel = :dataInicioProvavel"),
	@NamedQuery(name = "Turma.findByDataInicioReal", query = "SELECT t FROM Turma t WHERE t.dataInicioReal = :dataInicioReal"),
	@NamedQuery(name = "Turma.findByDataFinalProvavel", query = "SELECT t FROM Turma t WHERE t.dataFinalProvavel = :dataFinalProvavel"),
	@NamedQuery(name = "Turma.findByDataFinalReal", query = "SELECT t FROM Turma t WHERE t.dataFinalReal = :dataFinalReal"),
	@NamedQuery(name = "Turma.findByNumeroDeVagas", query = "SELECT t FROM Turma t WHERE t.numeroDeVagas = :numeroDeVagas"),
	@NamedQuery(name = "Turma.findByObservacoes", query = "SELECT t FROM Turma t WHERE t.observacoes = :observacoes")})
public class Turma implements Serializable {
	private static final long serialVersionUID = 1L;
	@Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Basic(optional = false)
        @Column(name = "id", nullable = false)
	private Integer id;
	@Basic(optional = false)
        @Column(name = "dataInicioProvavel", nullable = false)
        @Temporal(TemporalType.DATE)
	private Date dataInicioProvavel;
	@Column(name = "dataInicioReal")
        @Temporal(TemporalType.DATE)
	private Date dataInicioReal;
	@Basic(optional = false)
        @Column(name = "dataFinalProvavel", nullable = false)
        @Temporal(TemporalType.DATE)
	private Date dataFinalProvavel;
	@Column(name = "dataFinalReal")
        @Temporal(TemporalType.DATE)
	private Date dataFinalReal;
	@Basic(optional = false)
        @Column(name = "numeroDeVagas", nullable = false)
	private int numeroDeVagas;
	@Column(name = "observacoes", length = 45)
	private String observacoes;
	@JoinColumn(name = "facilitador_pessoa_id", referencedColumnName = "pessoa_id", nullable = false)
        @ManyToOne(optional = false)
	private Facilitador facilitador;
	@JoinColumn(name = "curso_id", referencedColumnName = "id", nullable = false)
        @ManyToOne(optional = false)
	private Curso curso;
	@OneToMany(cascade = CascadeType.ALL, mappedBy = "turma")
	private List<AlunoSubProgramaTurma> alunoSubProgramaTurmaList;

	public Turma() {
	}

	public Turma(Integer id) {
		this.id = id;
	}

	public Turma(Integer id, Date dataInicioProvavel, Date dataFinalProvavel, int numeroDeVagas) {
		this.id = id;
		this.dataInicioProvavel = dataInicioProvavel;
		this.dataFinalProvavel = dataFinalProvavel;
		this.numeroDeVagas = numeroDeVagas;
	}

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public Date getDataInicioProvavel() {
		return dataInicioProvavel;
	}

	public void setDataInicioProvavel(Date dataInicioProvavel) {
		this.dataInicioProvavel = dataInicioProvavel;
	}

	public Date getDataInicioReal() {
		return dataInicioReal;
	}

	public void setDataInicioReal(Date dataInicioReal) {
		this.dataInicioReal = dataInicioReal;
	}

	public Date getDataFinalProvavel() {
		return dataFinalProvavel;
	}

	public void setDataFinalProvavel(Date dataFinalProvavel) {
		this.dataFinalProvavel = dataFinalProvavel;
	}

	public Date getDataFinalReal() {
		return dataFinalReal;
	}

	public void setDataFinalReal(Date dataFinalReal) {
		this.dataFinalReal = dataFinalReal;
	}

	public int getNumeroDeVagas() {
		return numeroDeVagas;
	}

	public void setNumeroDeVagas(int numeroDeVagas) {
		this.numeroDeVagas = numeroDeVagas;
	}

	public String getObservacoes() {
		return observacoes;
	}

	public void setObservacoes(String observacoes) {
		this.observacoes = observacoes;
	}

	public Facilitador getFacilitador() {
		return facilitador;
	}

	public void setFacilitador(Facilitador facilitador) {
		this.facilitador = facilitador;
	}

	public Curso getCurso() {
		return curso;
	}

	public void setCurso(Curso curso) {
		this.curso = curso;
	}

	public List<AlunoSubProgramaTurma> getAlunoSubProgramaTurmaList() {
		return alunoSubProgramaTurmaList;
	}

	public void setAlunoSubProgramaTurmaList(List<AlunoSubProgramaTurma> alunoSubProgramaTurmaList) {
		this.alunoSubProgramaTurmaList = alunoSubProgramaTurmaList;
	}

	@Override
	public int hashCode() {
		int hash = 0;
		hash += (id != null ? id.hashCode() : 0);
		return hash;
	}

	@Override
	public boolean equals(Object object) {
		// TODO: Warning - this method won't work in the case the id fields are not set
		if (!(object instanceof Turma)) {
			return false;
		}
		Turma other = (Turma) object;
		if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public String toString() {
		return "entidades.Turma[id=" + id + "]";
	}

}
